home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Example script : Add two nurbs curves of the select list.
- //
- global proc int addTwoCurves()
- {
-
- ///////////////////////////////////////////////////
- // get the select list.
- //
- string $selList[] ;
- int $len ;
- $selList = `ls -sl` ;
- $len = size($selList) ;
- if( $len == 0 ) return 0 ;
-
- ///////////////////////////////////////////////////
- // run filter to get the nurbsCurves alone.
- //
- string $crvList[] ;
- global int $gSelectNurbsCurvesBit ;
- $crvList = `filterExpand -ex true -sm $gSelectNurbsCurvesBit` ;
- $len = size( $crvList ) ;
- if( $len != 2 ) return 0 ;
-
- /////////////////////////////////////////////
- // create average node.
- //
- int $ok = 1 ;
- int $sc = 0 ;
- string $avg ;
- if( catch($avg = `createNode avgCurves`) ) {
- $ok = 0 ;
- $sc = 1 ;
- }
-
- /////////////////////////////////////////////
- // connect input curves to average node.
- //
- if( $ok ) {
- string $inAttr1 ;
- string $inAttr2 ;
-
- string $shape1[] = `listRelatives -s $crvList[0]` ;
- $inAttr1 = $shape1[0] + ".ws[0]" ;
- string $shape2[] = `listRelatives -s $crvList[1]` ;
- $inAttr2 = $shape2[0] + ".ws[0]" ;
-
- string $oAttr1 ;
- string $oAttr2 ;
- $oAttr1 = $avg + ".ic1" ;
- $oAttr2 = $avg + ".ic2" ;
-
- if( catch( `connectAttr $inAttr1 $oAttr1` ) || catch( `connectAttr $inAttr2 $oAttr2` ) ) {
- $ok = 0 ;
- }
- if( $ok == 1 ) {
- //$inAttr1 = $avg + ".rb" ;
- //setAttr $inAttr1 0 ;
-
- // do not automate weights for averaging.
- //
- $inAttr1 = $avg + ".aw" ;
- setAttr $inAttr1 0 ;
- }
- }
-
- /////////////////////////////////////////////////////
- // curve shape to hold the weighted average result.
- //
- string $avgCurve ;
- if( $ok ) {
- if( catch( $avgCurve = `createNode nurbsCurve` ) ) {
- $ok = 0 ;
- } else {
- $sc = 1 ;
- }
- }
-
- /////////////////////////////////////////////////////
- // connect average node output to curve shape.
- //
- if( $ok ) {
- string $inAttr ;
- string $oAttr ;
- //string $shape[] = `listRelatives -s $avgCurve` ;
- $oAttr = $avgCurve + ".cr" ;
- $inAttr = $avg + ".oc" ;
- connectAttr $inAttr $oAttr ;
- }
-
- if( $ok ) {
- select -r $avgCurve ;
- } else {
- if( $sc == 1 ) delete $avg ;
- }
- return 1 ;
- }
-